package com.example.yuejian23.yuejian_23.Adapter;

import android.content.Context;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.yuejian23.yuejian_23.R;
import com.example.yuejian23.yuejian_23.javaBean.Replay;
import com.example.yuejian23.yuejian_23.javaBean.ShaituBean;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by dong on 2017/11/2.
 */

public class PinglunAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
    private Context mContext;
    private List mDataList;
    private LayoutInflater mlayoutInflater;
    public PinglunAdapter(Context mContext, List<Replay> mDataList){
        this.mContext = mContext;
        this.mDataList = mDataList;
        mlayoutInflater = LayoutInflater.from(mContext);

    }
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = mlayoutInflater.from(parent.getContext()).inflate(R.layout.pinglun, parent, false);
        return new PinglunAdapter.ViewHolder(v);
    }
    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        final Replay entity = (Replay) mDataList.get(position);
        if (null == entity)
            return;
        PinglunAdapter.ViewHolder viewHolder = (PinglunAdapter.ViewHolder) holder;
        viewHolder.name.setText(entity.getUname());
        viewHolder.yname.setText(entity.getRptext());
        Picasso.with(mContext).load("http://115.159.93.244/new18yuejian/Public/upload/"+entity.getUserpic()).into(viewHolder.pinglun_tou);

    }
    @Override
    public int getItemCount() {
        return mDataList.size();
    }
    private class ViewHolder extends RecyclerView.ViewHolder {
        TextView name,yname;
        ImageView pinglun_tou;

        public ViewHolder(View v) {
            super(v);
            name = (TextView) v.findViewById(R.id.name);
            yname = (TextView) v.findViewById(R.id.yname);
            pinglun_tou = (ImageView) v.findViewById(R.id.pinglun_tou);
        }
    }
}
